Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cookies

Package Overview
Dependencies
Maintainers
2
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cookies

Cookies, optionally signed using Keygrip.

  • 0.8.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is cookies?

The 'cookies' npm package is a Node.js module for handling browser cookies on the server side. It allows you to get and set HTTP cookies with a simple API, providing a way to manage session data and track user information across requests.

What are cookies's main functionalities?

Get a cookie

This feature allows you to retrieve the value of a cookie named 'LastVisit' from an incoming HTTP request.

const Cookies = require('cookies');
const cookies = new Cookies(req, res);
const lastVisit = cookies.get('LastVisit');

Set a cookie

This feature allows you to set a cookie with the name 'Name' and value 'Value', with additional options such as 'httpOnly' and 'secure' flags.

const Cookies = require('cookies');
const cookies = new Cookies(req, res);
cookies.set('Name', 'Value', { httpOnly: true, secure: true });

Set a cookie with expiration

This feature allows you to set a cookie that will expire one week from the current date.

const Cookies = require('cookies');
const cookies = new Cookies(req, res);
const oneWeekLater = new Date(Date.now() + 7 * 24 * 60 * 60 * 1000);
cookies.set('SessionToken', 'tokenValue', { expires: oneWeekLater });

Other packages similar to cookies

FAQs

Package last updated on 12 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc